package com.dys.testcopyonwritearrayList14;

import java.util.concurrent.CopyOnWriteArrayList;

/**
 * @className: com.dys.testcopyonwritearrayList14.CopyOnWriteArrayListTest
 * @description: com.dys.testcopyonwritearrayList14
 * @author: pine cone
 * @version: v1.0.0
 * @createTime: 2024/08/12 下午8:27
 */
public class CopyOnWriteArrayListTest {
    /**
     * 这是一个main()方法,是应用程序的入口
     *
     * @param args 方法的形参列表,是一个字符串数组,包含了从命令行传递给程序的参数
     */
    public static void main(String[] args) {
        new CopyOnWriteArrayListTest().testCopyOnWriteArrayList();
    }

    public void testCopyOnWriteArrayList() {
        CopyOnWriteArrayList<Integer> list = new CopyOnWriteArrayList<>();
        list.add(1);
        list.add(2);
        list.add(3);
        list.add(4);
        System.out.println(list.size());
        System.out.println(list);
        list.add(3);
        System.out.println(list);
        // list.addIfAbsent(4);
        list.addIfAbsent(44);
        System.out.println(list);
    }
}
